﻿<?php
session_start();
$_SESSION['_code']=rand(1,9999);
require('conn.php');
//require('session.php');
require('functions.php');
//print_r($userdata);

//全站访问
if($config['fangwen']==4){
	exit('网站正在更新');
}	
//有效访问时间
if(is_numeric($config['ReadTime'])){
	$readtime=$config['ReadTime']*1000;
}else{
	$readtime=0;
}
$aid=guolv($_GET['aid']);//文章id
$uid=guolv($_GET['uid']);//用户id
$ip=GetIP();

//获取文章信息
if(is_numeric($aid)){
	$row=$mysql->query("select * from `rw` where `id` in({$aid}) limit 1");
	if($row){
		$data=$row[0];
		$_pic=str_replace('[weixin]','',$data['pic']);
		// if($data['pv_max']!==0 || $data['pv_max']!=='-1'){
			// if($data['pv']>=$data['pv_max']){
				// exit('文章已过期');	
			// }
		// }


		 
	}else{
		exit('文章已过期');	
	}
}else{
	_location($site,301);
	exit;
}

//访问限制
if($config['fangwen']=='2,5'){
		if(is_weixin()==false || is_QQ()==false){
			$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
			echo "<title>{$data['title']}</title>";
			echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
			echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";	
			exit;//仅限微信、QQ访问
		}
}

if($config['fangwen']==1){
	if(is_mobile()==false){
		$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
		echo "<title>{$data['title']}</title>";
		echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
		echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";
		exit;//仅限手机访问
	}
}

if($config['fangwen']==2){
		if(is_weixin()==false){
			$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
			echo "<title>{$data['title']}</title>";
			echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
			echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";
			exit;//仅限微信访问		
		}
}

// setcookie("sdone");
// print_r($_COOKIE);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title><?php echo $data['title']?></title>
<meta name="keywords" content="<?php echo $data['title']?>"/>
<meta name="description" content="<?php echo $data['title']?>"/>
<link rel="stylesheet" type="text/css" href="static/hz.css" media="all">  

<style type="text/css">
body.mWrap {
	padding: 1.2em;
	overflow: hidden;
	/* [disabled]box-sizing: border-box; */
	-moz-box-sizing: border-box;
	-webkit-box-sizing: border-box;
}.mWrap {
    width: 100%;
    height: 100%;
    margin: 0 auto;
}body {
    font: 14px/1.5 "Microsoft Yahei";
    font-size: 62.5%;
    color: #333;
    background: #e4e4e4;
}.cttBg {
    padding: 0.8em 1.5em;
    background: #fff;
}.cttBg .form {
    font-size: 1.45em;
}
.form {
    margin: 0 0 0.5em;
    font-size: 1.68em;
    width: 100%;
}.form li {
    margin-bottom: 0.5em;
    width: 100%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
}.cttBg .form li:first-child span {
    font-weight: bold;
    font-size: 1.1em;
}
.blue {
    color: #0073c3;
}.form li {
    margin-bottom: 0.5em;
    width: 100%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
}.webuploader-container {
	position: relative;
}
.webuploader-element-invisible {
	position: absolute !important;
	clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
    clip: rect(1px,1px,1px,1px);
}
.webuploader-pick {
	position: relative;
	display: inline-block;
	cursor: pointer;
	background: #00b7ee;
	padding: 10px 15px;
	color: #fff;
	text-align: center;
	border-radius: 3px;
	overflow: hidden;    width: 100%; margin-top:20px
}
.webuploader-pick-hover {
	background: #00a2d4;
}

.webuploader-pick-disable {
	opacity: 0.6;
	pointer-events:none;
}
.uploader .thumbnail {
    width: 25%;
    max-height: 100px;
}
.file-item {
    float: left;
    position: relative;
 
    margin-top: 10px;
}  .btn {
    width: 100%;
    height: 2.64em;
    line-height: 2.64em;
    text-align: center;
    font-size: 1.11em;
    color: #fff;
    border: 0 none;
    cursor: pointer;
    background: #F9873C;
}  .thumbnail img {
    width: 95%;
    height: 100px;
    
}
</style>

</head>
<body class="mWrap">
<?php
 
 if($_POST){
	 
	 

	 
	 $title=guolv($_POST['title']);
 $nr=guolv($_POST['sm']);
 $photo1=guolv($_POST['photo1']);
 $photo2=guolv($_POST['photo2']);
  $photo3=guolv($_POST['photo3']);
   $photo4=guolv($_POST['photo4']);
    $user=$_SESSION['userdata']['id'];
  $rwuser=guolv($_POST['rwuser']);
 
 if($photo1==""){
	echo "<script>alert('请上传图片！');history.go(-1);</script>";
		exit;}

 
 
 
 
 $row=$mysql->query("select * from `rwsh` where `user` in({$user})  and `rwid` ={$aid} and zt=0  limit 1");
	if($row){
		
		
 
 
 if($user!=''){
 
	$mysql->query("update   `rwsh`    set 	img1='{$photo1}',img2='{$photo2}',img3='{$photo3}', img4='{$photo4}',zt=1,nr='{$nr}' where id=".$row[0]["id"]);
 
$id=mysql_insert_id();
 
 // $mysql->execute("update `rw` set  `cy`=cy+1  where `id`='{$aid}'");
 

 
	echo "<script>alert('任务提交成功，请耐心等待审核！');location.href='mylist.php'</script>";
 
	exit;
	}



}else{
	
	echo "<script>alert('您已经参加过此次任务！');location.href='mylist.php'</script>";
	}


}



?>
 <form action="" id="f1" method="post">
<section class="mContent">
		<article class="cttBg">
			<ul class="form">
				<li>
				 
				<span class="blue"><?php echo $data['title']?></span></li>
				<li>佣金：<?php echo $data['money']?></li>
				<li>结束时间：<?php echo $data['day']?></li>
				 <li>剩余：<?php echo $data['rs']-$data['cy']?> 人</li>
			 
			</ul>
		</article>
 
	</section>

	 
    <section class="mContent"  style="margin-top:20px">
		<article class="cttBg">
			<ul class="form">
				<li >
				 
			<?php echo $data['content']?></li>
				 
			 
			</ul>
		</article>
 
	</section>   
   
		          <?php
    
    	 if($data['cy']<$data['rs']){
		 
		 
		 
		 ?>
   <?php 
    if(strtotime($data['day'])>strtotime(date("Y-m-d"))){
		
		?>   <section class="mContent"  style="margin-top:20px">
      <li>说明： </li>
      
      <input name="title" type="hidden" value="<?php echo $data['title']?>">
         <input name="rwid" type="hidden" value="<?php echo $aid?>">
          <input name="rwuser" type="hidden" value="<?php echo $data['userid']?>">
    <textarea name="sm" cols="" rows="5" style="width:100%"  ></textarea></section>  
<div id="preview"></div>
 </form>
 
 
 <style type="text/css">
.demo{width:100%; margin:20px auto 0 auto; min-height:20px;}
.preview{width:100px; height:100px;border:solid 1px #dedede; margin:10px;padding:10px;}
.demo p{line-height:26px}
.btn{
	position: relative;
	overflow: hidden;
	margin-right: 4px;
	display: inline-block;
*display:inline;	font-size: 14px;
	line-height: 18px;
*line-height:20px;	color: #fff;
	text-align: center;
	vertical-align: middle;
	cursor: pointer;
	background-color: #5bb75b;
	border: 1px solid #cccccc;
	border-color: #e6e6e6 #e6e6e6 #bfbfbf;
	border-bottom-color: #b3b3b3;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
	border-radius: 4px;
	width: 100%;
	padding-top: 4px;
 
	padding-bottom: 4px;
 
}
.btn input {position: absolute;top: 0; right: 0;margin: 0;border: solid transparent;opacity: 0;filter:alpha(opacity=0); cursor: pointer;}
</style>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.wallform.js"></script>
<script type="text/javascript">
var i=1;
$(function(){
	$('#photoimg').die('click').live('change', function(){
		var status = $("#up_status");
		var btn = $("#up_btn");
		$("#imageform").ajaxForm({
			target: '#preview', 
			beforeSubmit:function(){
				status.show();
				btn.hide();
			}, 
			success:function(){
				status.hide();
				btn.show();
				i=i+1;
				$("#imgi").val(i);
				
				 
			}, 
			error:function(){
				status.hide();
				btn.show();
		} }).submit();
	});
});

function tj(){$('#f1').submit();}
</script>
 
 
 
  <div class="demo">

        
        <form id="imageform" method="post" enctype="multipart/form-data" action="upload.php"> <input name="rwid" type="hidden" value="<?php echo $aid?>">
          <input name="imgi" id="imgi" type="hidden" value="1">
			<div id="up_status" style="display:none"><img src="loader.gif" alt="uploading"/></div>
			<div id="up_btn" class="btn">
				<span>添加图片</span>
				<input id="photoimg" type="file" style="width:100%" name="photoimg">
			</div>
		</form>
      
		
</div>
	
  
  <br/>
</div>

 
 
 
 
 
 

   <section class="mContent"  style="margin-top:20px">
			<li><input   type="button" onClick="tj()" class="btn" value="提交"  ></li>
	</section>
	 <?php
    }
	}?>
</body>
</html>
